//
//  Notification+EQ.swift
//  EQQuestionBank
//
//  Created by 范伟健 on 2018/8/6.
//  Copyright © 2018年 FanWeiJian. All rights reserved.
//

import Foundation
import RxSwift

enum EQNotification: String {
    
    case pushAnalysisVC
    
    var stringValue: String {
        return "EQ" + rawValue
    }
    
    var notificationName: NSNotification.Name {
        return NSNotification.Name(stringValue)
    }
}

//扩展通知的post方法
extension NotificationCenter {
    static func post(customeNotification name: EQNotification, object: Any? = nil){
        NotificationCenter.default.post(name: name.notificationName, object: object)
    }
    
    static func post<T>(customeNotification name: EQNotification, object: T? = nil){
        NotificationCenter.default.post(name: name.notificationName, object: object)
    }
    
}
//扩展rx监听通知
extension Reactive where Base: NotificationCenter {
    func notification(custom name: EQNotification, object: AnyObject? = nil) -> Observable<Notification> {
        return notification(name.notificationName, object: object)
    }
}
